<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button id="btn">点我创建一个输入框</button>
    <script>
        let btn = document.getElementById('btn')
        btn.onclick = ()=>{
            let input = document.createElement('input')
            //这些操作可以放在input被插入页面之前
            input.style.backgroundColor = 'orange'
            input.value = 99
            input.onclick = ()=>{
                alert(1)
            }

            //将input插入页面
            document.body.appendChild(input)
        
            //这些操作必须放在input插入页面之后
            input.focus()
            input.parentElement.style.backgroundColor = 'skyblue'
        }
    </script>
</body>
</html>